<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>margin负值情况</title>
    <style>
        #outer {
            height: 300px;
            width: 300px;
        }
        
        #outer .outer-div1 {
            height: 100px;
            width: 100px;
            border: 1px solid hotpink;
            margin-bottom: -20px;
        }
        
        #outer .outer-div2 {
            height: 100px;
            width: 100px;
            border: 1px solid skyblue;
        }
        
        .footer {
            height: 300px;
            width: 300px;
        }
        
        .clearfix::after {
            content: '';
            display: table;
            clear: both;
        }
        
        .footer .div1 {
            height: 100px;
            width: 100px;
            border: 1px solid skyblue;
            float: left;
        }
        
        .footer .div2 {
            height: 100px;
            width: 100px;
            border: 1px solid hotpink;
            float: left;
        }
    </style>
</head>

<body>
    <p>magin 负值情况</p>
    <div id="outer">
        <div class="outer-div1">outer-div1</div>
        <div class="outer-div2">outer-div2</div>
    </div>
    <p>margin 垂直负值情况</p>
    <div class="footer clearfix">
        <div class="div1">div1</div>
        <div class="div2">div2</div>
    </div>
</body>

</html>